package com.huawei.hgip.paintgame.app;


import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.huawei.hgip.paintgame.R;
import com.huawei.hgip.paintgame.widget.ColorPickerDialog;
import com.huawei.hgip.paintgame.widget.FingerPaintView;
import com.huawei.hgip.paintgame.widget.FingerPaintView.PaintStyles;

/**
 * 画图板页面
 * @author Administrator
 *
 */
public class PaintActivity extends ZZYYActivity implements ColorPickerDialog.OnColorChangedListener {
	
	private FingerPaintView myFPView;
//	private Paint       mPaint;
    
    public void colorChanged(int color) {
    	myFPView.setPaintColor(color);
    }
	
	//@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.paintview);
        
        myFPView = (FingerPaintView) findViewById(R.id.myFPview);
        
    }
	
	private static final int COLOR_MENU_ID = Menu.FIRST;
    private static final int EMBOSS_MENU_ID = Menu.FIRST + 1;
    private static final int BLUR_MENU_ID = Menu.FIRST + 2;
    private static final int ERASE_MENU_ID = Menu.FIRST + 3;
    private static final int SRCATOP_MENU_ID = Menu.FIRST + 4;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        
        menu.add(0, COLOR_MENU_ID, 0, "颜色").setShortcut('3', 'c');
        menu.add(0, EMBOSS_MENU_ID, 0, "立体笔触").setShortcut('4', 's');
        menu.add(0, BLUR_MENU_ID, 0, "喷涂笔触").setShortcut('5', 'z');
        menu.add(0, ERASE_MENU_ID, 0, "橡皮擦").setShortcut('5', 'z');
        menu.add(0, SRCATOP_MENU_ID, 0, "SrcATop").setShortcut('5', 'z');

        /****   Is this the mechanism to extend with filter effects?
        Intent intent = new Intent(null, getIntent().getData());
        intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
        menu.addIntentOptions(
                              Menu.ALTERNATIVE, 0,
                              new ComponentName(this, NotesList.class),
                              null, intent, 0, null);
        *****/
        return true;
    }
    
    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        switch (item.getItemId()) {
            case COLOR_MENU_ID:
                new ColorPickerDialog(this, this, myFPView.getPaintColor()).show();
                return true;
            case EMBOSS_MENU_ID:
                myFPView.setPaintStyle(PaintStyles.EMBOSS);
                return true;
            case BLUR_MENU_ID:
                myFPView.setPaintStyle(PaintStyles.BLUR);
                return true;
            case ERASE_MENU_ID:
            	myFPView.setPaintStyle(PaintStyles.ERASE);
                return true;
            case SRCATOP_MENU_ID:
            	myFPView.setPaintStyle(PaintStyles.SRCATOP);
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

}
